using EFCoreSnowFlakeIdDemo.WebApi.Models;
using Microsoft.AspNetCore.Mvc;

namespace EFCoreSnowFlakeIdDemo.WebApi.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class OrderController : ControllerBase
    {
        private readonly OrderDbContext _dbContext;

        public OrderController(OrderDbContext dbContext)
        {
            _dbContext = dbContext;
        }

        [HttpPost]
        public async Task<string> CreateAsync()
        {
            var order = new Order();
            await _dbContext.Orders.AddAsync(order);
            await _dbContext.SaveChangesAsync();
            return order.Id.ToString();
        }
    }
}